<?php
namespace App\Query;

use App\Model\UserTransfer;
use App\Query\Traits\UserTrait;

class UserTransferQuery extends \HyperfStore\Query
{
    use UserTrait;
    
    // 构建模型
    protected static function build()
    {
        return UserTransfer::latest();
    }

    // 渴望加载
    protected static function with()
    {
        return ['user', 'toUser'];
    }
    
    // 时间区间
    protected static function queryTime($model, $where)
    {
        return $model->whereBetween('created_at', $where);
    }
    
    // 转给我的
    public static function toUser($model)
    {
        return static::model()->where('to_user_id', $model->id);
    }
}